home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / BODI / FAST.S < prev    next >
Encoding:
Text File  |  2001-02-10  |  16.9 KB  |  661 lines

  1. **********************************************************************    
  2. * FILE:    FAST.S                                 *
  3. * DATE: November 6, 1989                         *
  4. * DESCRIPTION: Rewrites of many of the conversion routines in...     *
  5. *           CONVERT.C                         *
  6. *           ASM.C                             *
  7. *           IFOUT.C                             *
  8. **********************************************************************    
  9. false equ 0
  10. true  equ $FFFF
  11. STUFF equ true
  12. SCALED equ true
  13.  
  14. **********************************************************************
  15. * VARIABLES                                 *
  16. **********************************************************************    
  17.     .globl     _zdevice            ;Device index
  18.     .globl     _axdpi                ;xdpi array
  19.     .globl     _aydpi                ;ydpi array
  20.     .globl     _xdpi                ;GOG xdpi array
  21.     .globl     _ydpi                ;GOG ydpi array
  22.     .globl     _sdevm                ;GOG index into array
  23.     .globl     _zrat                ;GOG variable for ratio to use
  24.     .globl     _pgeptr
  25.     .globl     _pixtbl
  26.  
  27. **********************************************************************    
  28. * FUNCTIONS                                 *
  29. **********************************************************************    
  30.     .globl     _hmupix            ; Horizontal Machine Units to Pixel
  31.     .globl     _vmupix            ; Vertical Machine Units to Pixel
  32.     .globl     _hpixmu            ; Horizontal Pixel to Machine Units
  33.     .globl     _vpixmu            ; Vertical Pixel to Machine Units
  34.     .globl     _scaler            ; Scaler routine
  35.     .globl     _scaleme            ; Replaces scale_me()
  36.  
  37.     .globl     _worldx            ; MU to Pixel conversion GOG
  38.     .globl     _worldy            ; MU to Pixel conversion GOG
  39.     .globl     _zvalue            ; SCALER GOG
  40.  
  41.     .globl     _f_move            ; forward block moves    GOG
  42.     .globl     _Lf_move            ; long forward block moves GOG
  43.     .globl     _r_move            ; reverse block moves GOG
  44.     .globl     _Lr_move            ; long reverse block moves GOG
  45.  
  46.     .globl     _put_pix
  47.  
  48. **********************************************************************
  49. * Horizontal Machine Units to Pixel Conversions                 *
  50. * Handles negative numbers too                         *
  51. * Formerly hmutopix()                             *
  52. * IN:          D0 - Units to convert (munits)(signed)             *
  53. *                                     *
  54. * INTERNAL:    A0 - axdpi array                     *
  55. *         D1 - index into xdpi array                 *
  56. *                                     *
  57. * OUT:         D0 - converted number                     *
  58. *                                     *
  59. * Algorithm:    ( munits * axdpi(zdevice) + 648)/1296             *
  60. **********************************************************************
  61. _hmupix:
  62.     move.w    _zdevice,d1            ;get index
  63.     add.w    d1,d1                ;double it to get bytes
  64.     lea    _axdpi,a0            ;get array
  65.     move.w    4(sp),d0            ;munits
  66.     bmi.s    .10                ;branch if neg
  67.     mulu    (a0,d1.w),d0            ;munits * axdpi[zdevice]
  68.     add.l    #648,d0                ;add 648
  69.     divu    #1296,d0            ;divide by 1296
  70.     rts
  71. .10:
  72.     neg.w    d0                ;handle sign
  73.     mulu    (a0,d1.w),d0            ;munits * axdpi[zdevice]
  74.     add.l    #648,d0                ;add 648
  75.     divu    #1296,d0            ;divide by 1296
  76.     neg.w    d0                ;restore sign
  77.     rts
  78.  
  79.  
  80. **********************************************************************    
  81. * Vertical Machine Units to Pixel Conversion                 *
  82. * Formerly vmutopix()                             *
  83. * Handles negative numbers too                         *
  84. * IN:        d0 - Number to convert (munits)    (signed)         *
  85. *                                     *
  86. * INTERNAL:    a0 - aydpi array                     *
  87. *        d1 - zdevice - index into aydpi array             *
  88. *                                     *
  89. * OUT:        d0 - converted units                     *
  90. *                                     *
  91. * Algorithm:    (munits * aydpi[zdevice] + 576)/1152             *
  92. **********************************************************************        
  93. _vmupix:
  94.     move.w    _zdevice,d1            ;Index into aydpi array
  95.     add.w    d1,d1                ;double to get bytes
  96.     lea    _aydpi,a0            ;get aydpi array
  97.     move.w    4(sp),d0            ;munits
  98.     bmi.s    .10                ;branch if neg
  99.     mulu    (a0,d1.w),d0            ;munits * aydpi[zdevice]
  100.     add.l    #576,d0                ;add 576
  101.     divu    #1152,d0            ;divide by 1152
  102.     rts
  103. .10:
  104.     neg.w    d0                ;handle the sign
  105.     mulu    (a0,d1.w),d0            ;munits * aypdi[zdevice]
  106.     add.l    #576,d0                ;add 576
  107.     divu    #1152,d0            ;divide by 1152
  108.     neg.w    d0                ;restore sign
  109.     rts
  110.     
  111.  
  112. **********************************************************************    
  113. * Horizontal Pixel to Machine Units                     *
  114. * Formerly hpixtomu()                             *
  115. * Handles negative numbers too!                         *
  116. * IN:        d0 - number to convert (pixels)(signed)             *
  117. *                                     *
  118. * INTERNAL:    d1 - zdevice - index into axdpi array             *
  119. *        a0 - axdpi array                     *
  120. *        d2 - xdpi/2                         *
  121. *        d3 - current xdpi                     *
  122. *                                     *
  123. * OUT:        d0 - converted number in munits                 *
  124. *                                      *
  125. * Algorithm:    (pixels * 1296 + (axdpi[zdevice]/2))/axdpi[zdevice]  *
  126. **********************************************************************        
  127. _hpixmu:
  128.     move.w    _zdevice,d1            ;Get index into array
  129.     add.w    d1,d1                ;get it in byes    
  130.     lea    _axdpi,a0            ;get array
  131.     moveq    #0,d2
  132.     move.w    (a0,d1.w),d2            ;put xdpi into d2
  133.     move.l    d2,d3                ;copy to d3
  134.     asr.l    #1,d2                ;Get xdpi/2
  135.     move.w    4(sp),d0            ;pixels
  136.     bmi.s    .10                ;branch if negative
  137.     mulu    #1296,d0            ;pixels * 1296
  138.     add.l    d2,d0                ;add xdpi/2
  139.     divu    d3,d0                ;divide by xdpi
  140.     rts
  141. .10:
  142.     neg.w    d0                ;make positive
  143.     mulu    #1296,d0            ;pixels * 1296
  144.     add.l    d2,d0                ;add xdpi/2
  145.     divu    d3,d0                ;divide by xdpi
  146.     neg.w    d0                ;restore sign
  147.     rts
  148.  
  149.  
  150.  
  151. **********************************************************************    
  152. * Vertical Pixel to Machine Units                     *
  153. * Formerly vpixtomu()                             *
  154. * Handles negative numbers too!                         *
  155. * IN:        d0 - number to convert (pixels)(signed)             *
  156. *                                     *
  157. * INTERNAL:    d1 - zdevice - index into aydpi array             *
  158. *        a0 - aydpi array                     *
  159. *        d2 - ydpi /2                         *
  160. *        d3 - current y dpi                     *
  161. *                                     *
  162. * OUT:        d0 - converted number in munits                 *
  163. *                                     *
  164. * Algorithm:    (pixels * 1152 + aydpi[zdevice]/2)/aydpi[zdevice]    *
  165. **********************************************************************    
  166. _vpixmu:
  167.     move.w    _zdevice,d1            ;Get index into array
  168.     add.w    d1,d1                ;get it in bytes
  169.     lea    _aydpi,a0            ;get array
  170.     moveq    #0,d2
  171.     move.w    (a0,d1.w),d2            ;get dpi
  172.     move.l    d2,d3                ;copy it to d3
  173.     asr.l    d2                ;get ydpi/2
  174.     move.w    4(sp),d0            ;pixels
  175.     bmi.s    .10                ;branch if negative
  176.     mulu    #1152,d0            ;pixels * 1152
  177.     add.l    d2,d0                ;add ydpi/2
  178.     divu    d3,d0                ;divide by ydpi
  179.     rts
  180. .10:
  181.     neg.w    d0                ;make positive
  182.     mulu    #1152,d0            ;pixels * 1152
  183.     add.l    d2,d0                ;add ydpi/2
  184.     divu    d3,d0                ;divide by ydpi
  185.     neg.w    d0                ;restore sign
  186.     rts
  187.  
  188.  
  189. .if SCALED
  190. **********************************************************************    
  191. * General Purpose Scaler                         *
  192. * Replaces scale_iv() and scale_v()                     *
  193. * Algorithm: (visible * factor + total/2)/total                 *
  194. * where A,B and C are signed.                         *
  195. * IN:        d0 - visible (signed)                     *
  196. *        d1 - total   (signed)                     *
  197. *                                     *
  198. * INTERNAL:    d2 - total/2                         *
  199. *                                     *
  200. * OUT:        d0 - Returns converted number                 *
  201. **********************************************************************    
  202. _scaler:
  203.     move.w    4(sp),d0    
  204.     move.w    8(sp),d1
  205.     move.w    d1,d2
  206.     muls    6(sp),d0
  207.     bmi.s    .10
  208.     asr.w    #1,d2
  209.     bpl.s    .11
  210.     bra.s    .12
  211. .10:
  212.     asr.w    #1,d2
  213.     bmi.s    .11
  214. .12:
  215.     neg.w    d2
  216. .11:    
  217.     ext.l    d2
  218.     add.l    d2,d0
  219.     divs    d1,d0
  220.     rts
  221. .endif
  222.  
  223. **********************************************************************    
  224. * GOG World to x Coordinates                         *
  225. * Replace world_rc_x()                             *
  226. * Also, this incorporates zvalue directly into the routine         *
  227. * IN:        d0 - number to be converted to pixels(signed)         *
  228. *                                     *
  229. * INTERNAL:                                 *
  230. *            zvalue: d1 - ratio(100,75,50 etc - zrat)         *
  231. *                                     *            
  232. *        scaler: d1 - sdevm (index into xdpi array)         *
  233. *            a0 - xdpi array                     *
  234. *                                     *
  235. * OUT:        d0 - converted number                     *
  236. *                                     *
  237. * Algorithm:    (a * b + c/2)/c                         *
  238. **********************************************************************    
  239. _worldx:
  240.     move.w    _zrat,d1        ;Get current ratio
  241.     move.w    4(sp),d0        ;get pixels
  242.     bmi.s    .11            ;branch if negative
  243.     cmpi.w    #100,d1            ;check current ratio
  244.     beq.s    .10            ;skip zvalue handling if 100%
  245.     mulu    d1,d0            ;handle zvalue - zrat * pixel
  246.     add.l    #50,d0            ;add 50
  247.     divu    #100,d0            ;divide by 100
  248. *
  249. .10:                    ;handle number AFTER zvalue handling
  250.     move.w    _sdevm,d1        ;Index int xdpi array
  251.     add.w    d1,d1            ;convert to bytes
  252.     lea    _xdpi,a0        ;get array
  253.     mulu    (a0,d1.w),d0        ;pixels * xdpi[sdevm]
  254.     add.l    #648,d0            ;add 648
  255.     divu    #1296,d0        ;divide by 1296
  256.     rts
  257. *
  258. .11:                    ;Negative #s
  259.     neg.w    d0            ;make positive
  260.     cmpi.w    #100,d1            ;if 100%
  261.     beq.s    .12            ;skip zvalue handling
  262.     mulu    d1,d0            ;pixels * zrat
  263.     add.l    #50,d0            ;add 50
  264.     divu    #100,d0            ;divide by 100
  265. *
  266. .12:                    ;handle #s AFTER zvalue handling
  267.     move.w    _sdevm,d1        ;get index into xdpi array
  268.     add.w    d1,d1            ;convert to bytes
  269.     lea    _xdpi,a0        ;get array
  270.     mulu    (a0,d1.w),d0        ;pixels * xdpi[sdevm]
  271.     add.l    #648,d0            ;add 648
  272.     divu    #1296,d0        ;divide by 1296
  273.     neg.w    d0            ;restore sign
  274.     rts
  275.  
  276.  
  277.  
  278. **********************************************************************    
  279. * GOG World to Y Coordinates                         *
  280. * Replaces world_rc_y()                             *
  281. * Includes zvalue() internally                         *
  282. * IN:        d0 - number to convert (pixels)(signed)             *
  283. *                                     *
  284. * INTERNAL:                                 *
  285. *    zvalue: d1 - zrat (ratio 100,75,etc)                 *
  286. *                                     *
  287. *    scaler: d1 - sdevm (index into ydpi array)             *
  288. *        a0 - ydpi array                         *
  289. *                                     *
  290. * OUT:        d0 - Converted number                     *
  291. *                                     *
  292. * Algorithm:     (a * b + c/2)/c                         *
  293. **********************************************************************    
  294. _worldy:
  295.     move.w    _zrat,d1        ;Get zratio             
  296.     move.w    4(sp),d0        ;get pixels
  297.     bmi.s    .11            ;branch if negative number
  298.     cmpi.w    #100,d1            ;if 100%...
  299.     beq.s    .10            ;skip zvalue handling
  300.     mulu    d1,d0            ;pixels * zrat
  301.     add.l    #50,d0            ;add 50
  302.     divu    #100,d0            ;divide by 100
  303. *
  304. .10:                    ;handle # AFTER zvalue
  305.     move.w    _sdevm,d1        ;get index into array
  306.     add.w    d1,d1            ;convert to bytes
  307.     lea    _ydpi,a0        ;get array
  308.     mulu    (a0,d1.w),d0        ;pixels * ydpi[sdevm]
  309.     add.l    #576,d0            ;add 576
  310.     divu    #1152,d0        ;divide by 1152
  311.     rts
  312. *
  313. .11:                    ;negative number
  314.     neg.w    d0            ;make positive
  315.     cmpi.w    #100,d1            ;if 100%
  316.     beq.s    .12            ;skip zvalue handling
  317.     mulu    d1,d0            ;pixel * zrat
  318.     add.l    #50,d0            ;add 50
  319.     divu    #100,d0            ;divide by 100
  320. *
  321. .12:                    ;handle neg values AFTER zvalue
  322.     move.w    _sdevm,d1        ;get index into array
  323.     add.w    d1,d1            ;convert to bytes
  324.     lea    _ydpi,a0        ;get array    
  325.     mulu    (a0,d1.w),d0        ;pixels * ydpi[sdevm]
  326.     add.l    #576,d0            ;add 576
  327.     divu    #1152,d0        ;divide by 1152
  328.     neg.w    d0            ;restore sign
  329.     rts
  330.  
  331.  
  332. **********************************************************************    
  333. * GOG ZVALUE() rewritten                         *
  334. * IN:        d0 - number to be converted    (signed)         *
  335. *                                     *
  336. * INTERNAL:    d1 - zrat (current ratio 100,75,50 etc)             *
  337. *                                     *
  338. * OUT:        d0 - converted number                     *
  339. *                                     *
  340. * Algorithm: (a * b + 50)/100                         *
  341. **********************************************************************    
  342. _zvalue:
  343.      move.w    _zrat,d1        ;get ratio
  344.      cmpi.w    #100,d1            ;we at 100%?
  345.      beq.s    .11            ;skip entirely if so...
  346.      move.w    4(sp),d0        ;get number to convert
  347.      bmi.s    .10            ;branch if negative
  348.      mulu    d1,d0            ;num * zrat
  349.      add.l    #50,d0            ;add 50
  350.      divu    #100,d0            ;divide by 100
  351.      rts
  352. .10:
  353.      neg.w    d0            ;make positive
  354.      mulu    d1,d0            ;num * zrat
  355.      add.l    #50,d0            ;add 50
  356.      divu    #100,d0            ;divide by 100
  357.      neg.w    d0            ;restore sign
  358. .11:    
  359.     rts
  360.  
  361.  
  362. **********************************************************************    
  363. * FUNCTION: _scaleme()                             *
  364. * Formerly scale_me() in convert.c                     *
  365. * IN:        d0 - number to scale    (signed)             *
  366. *        d1 - scaler        (unsigned)             *
  367. *        d2 - flag 0 - convert from mu to percentage         *
  368. *                                     *
  369. * INTERNAL:    d3 - scaler/2                         *
  370. *                                     *
  371. * OUT:        d0 - converted number                     *
  372. *                                      *
  373. * Algorithm:    (a * b + c/2)/c                         *
  374. **********************************************************************    
  375. _scaleme:
  376.     moveq    #0,d1
  377.     move.w    6(sp),d1    ; scaler
  378.     move.w    8(sp),d2    ; flag
  379.     tst.b    d2        ; test the flag
  380.     bne.s     .10        ; 1 or 0?
  381.     move.w    4(sp),d0    ; convert from mu to percentage
  382.     bmi.s    .11        ; branch if minus
  383.     mulu    d1,d0        ; num * scaler
  384.     add.l    #50,d0        ; add 50
  385.     divu    #100,d0        ; divide by 100
  386.     rts
  387. *    
  388. .11:                ; negative
  389.     neg.w    d0        ; make positive
  390.     mulu    d1,d0        ; num * scaler
  391.     add.l    #50,d0        ; add 50
  392.     divu    #100,d0        ; divide by 100
  393.     neg.w    d0        ; restore sign
  394.     rts
  395. *
  396. .10:                ; Convert from percentage to mu
  397.     move.l    d1,d3        ; copy scaler
  398.     asr.l    #1,d3        ; divide it by 2
  399.     move.w    4(sp),d0    ; get number
  400.     bmi.s    .12        ; branch if minus
  401.     mulu    #100,d0        ; num * 100
  402.     add.l    d3,d0        ; add scaler/2
  403.     divu    d1,d0        ; divide by scaler
  404.     rts
  405. *
  406. .12:                ; negative
  407.     neg.w    d0        ; make positive
  408.     mulu    #100,d0        ; num * 100
  409.     add.l    d3,d0        ; add scaler/2
  410.     divu    d1,d0        ; divide by scaler
  411.     neg.w    d0        ; restore sign
  412.     rts
  413.  
  414.  
  415. **********************************************************************
  416. * FUNCTIONS: _f_move() and _Lf_move()                     *
  417. * Replaces the fmove() and Lf_move() in asm.c                 *
  418. * and takes into account whether the src/dst and count are odd/even  *
  419. * when even, we can do word moves instead of byte moves             *
  420. **********************************************************************
  421. _f_move:
  422.     move.l    4(sp),d0    ;SRC
  423.     move.l  8(sp),d1    ;DST
  424.     moveq    #0,d2
  425.     move.w    12(sp),d2    ;COUNT
  426.     bra.s    _entry        ;br to rest of routine
  427.  
  428. _Lf_move:
  429.     lea    4(sp),a0
  430.     movem.l    (a0),d0-d2    ;d0-> SRC, d1-> DST, d2.l = count
  431. _entry:
  432.     move.l    d0,a0        ;copy SRC to a0
  433.     move.l    d1,a1        ;copy DST to a1
  434.     eor.w    d1,d0        ;check for ODD/EVEN or EVEN/ODD SRC/DST
  435.     andi.w    #1,d0
  436.     bne.s    .oddeveni    ;br if mixed ODD/EVEN SRC/DST;do bytes
  437.  
  438. *
  439. *    SRC/DST are both either ODD/ODD or EVEN/EVEN...
  440. *
  441.     lsr.l    #1,d2        ;divide count by 2 for word moves
  442.     bcc.s    .evcount    ;br if even count
  443. *
  444. *    COUNT is ODD... (must be at least 1)
  445. *
  446.     andi.w    #1,d1        ;is SRC/DST EVEN/EVEN or ODD/ODD?
  447.     beq.s    .doev        ;br if EVEN/EVEN
  448. *
  449. *    SRC/DST is ODD/ODD
  450. *
  451.     move.b    (a0)+,(a1)+    ;need to start w/byte move
  452.     bra.s    .oddoddi
  453. .oddotop:
  454.     swap    d2
  455. .oddodd:
  456.     move.w    (a0)+,(a1)+
  457. .oddoddi:
  458.     dbra    d2,.oddodd
  459.     swap    d2
  460.     dbra    d2,.oddotop
  461.     rts
  462. *
  463. *
  464. *
  465. .evnetop:
  466.     swap    d2
  467. .evnevn:
  468.     move.w    (a0)+,(a1)+
  469. .doev:
  470.     dbra    d2,.evnevn
  471.     swap    d2
  472.     dbra    d2,.evnetop
  473.     move.b    (a0)+,(a1)+
  474.     rts
  475. *
  476. *    COUNT is EVEN
  477. *
  478. .evcount:
  479.     andi.w    #1,d1        ;is SRC/DST EVEN/EVEN or ODD/ODD?
  480.     beq.s    .doevx        ;br if EVEN/EVEN
  481. *
  482. *    SRC/DST is ODD/ODD
  483. *
  484.     subq.l    #1,d2        ;is count = 0?
  485.     bmi.s    .oddxx        ;exit if so...
  486. *
  487.     move.b    (a0)+,(a1)+    ;need to start w/byte move
  488.     bra.s    .oddoddxi
  489. .oddotopx:
  490.     swap    d2
  491. .oddoddx:
  492.     move.w    (a0)+,(a1)+
  493. .oddoddxi:
  494.     dbra    d2,.oddoddx
  495.     swap    d2
  496.     dbra    d2,.oddotopx
  497.     move.b    (a0)+,(a1)+
  498. .oddxx:
  499.     rts
  500. *
  501. *
  502. *
  503. .evnetopx:
  504.     swap    d2
  505. .evnevnx:
  506.     move.w    (a0)+,(a1)+
  507. .doevx:
  508.     dbra    d2,.evnevnx
  509.     swap    d2
  510.     dbra    d2,.evnetopx
  511.     rts
  512. *
  513. *
  514. *    need to use byte moves
  515. .oddevtop:
  516.     swap    d2
  517. .oddeven:
  518.     move.b    (a0)+,(a1)+
  519. .oddeveni:
  520.     dbra    d2,.oddeven
  521.     swap    d2
  522.     dbra    d2,.oddevtop
  523.     rts
  524.  
  525.  
  526.  
  527. **********************************************************************
  528. * FUNCTIONS: _r_move() and _Lr_move()                     *
  529. * Replaces the fmove() and Lf_move() in asm.c                 *
  530. * and takes into account whether the src/dst and count are odd/even  *
  531. * when even, we can do word moves instead of byte moves             *
  532. **********************************************************************
  533. _r_move:
  534.     move.l    4(sp),d0    ;SRC
  535.     move.l  8(sp),d1    ;DST
  536.     moveq    #0,d2
  537.     move.w    12(sp),d2    ;COUNT
  538.     bra.s    _entry2        ;br to rest of routine
  539.  
  540. _Lr_move:
  541.     lea    4(sp),a0
  542.     movem.l    (a0),d0-d2    ;d0-> SRC, d1-> DST, d2.l = count
  543. _entry2:
  544.     addq.l    #1,d0
  545.     addq.l    #1,d1
  546.     move.l    d0,a0        ;copy SRC to a0
  547.     move.l    d1,a1        ;copy DST to a1
  548.     eor.w    d1,d0        ;check for ODD/EVEN or EVEN/ODD SRC/DST
  549.     andi.w    #1,d0
  550.     bne.s    .oddeveni    ;br if mixed ODD/EVEN SRC/DST;do bytes
  551.  
  552. *
  553. *    SRC/DST are both either ODD/ODD or EVEN/EVEN...
  554. *
  555.     lsr.l    #1,d2        ;divide count by 2 for word moves
  556.     bcc.s    .evcount    ;br if even count
  557. *
  558. *    COUNT is ODD... (must be at least 1)
  559. *
  560.     andi.w    #1,d1        ;is SRC/DST EVEN/EVEN or ODD/ODD?
  561.     beq.s    .doev        ;br if EVEN/EVEN
  562. *
  563. *    SRC/DST is ODD/ODD
  564. *
  565.     move.b    -(a0),-(a1)    ;need to start w/byte move
  566.     bra.s    .oddoddi
  567. .oddotop:
  568.     swap    d2
  569. .oddodd:
  570.     move.w    -(a0),-(a1)
  571. .oddoddi:
  572.     dbra    d2,.oddodd
  573.     swap    d2
  574.     dbra    d2,.oddotop
  575.     rts
  576. *
  577. *
  578. *
  579. .evnetop:
  580.     swap    d2
  581. .evnevn:
  582.     move.w    -(a0),-(a1)
  583. .doev:
  584.     dbra    d2,.evnevn
  585.     swap    d2
  586.     dbra    d2,.evnetop
  587.     move.b    -(a0),-(a1)
  588.     rts
  589. *
  590. *    COUNT is EVEN
  591. *
  592. .evcount:
  593.     andi.w    #1,d1        ;is SRC/DST EVEN/EVEN or ODD/ODD?
  594.     beq.s    .doevx        ;br if EVEN/EVEN
  595. *
  596. *    SRC/DST is ODD/ODD
  597. *
  598.     subq.l    #1,d2        ;is count = 0?
  599.     bmi.s    .oddxx        ;exit if so...
  600. *
  601.     move.b    -(a0),-(a1)    ;need to start w/byte move
  602.     bra.s    .oddoddxi
  603. .oddotopx:
  604.     swap    d2
  605. .oddoddx:
  606.     move.w    -(a0),-(a1)
  607. .oddoddxi:
  608.     dbra    d2,.oddoddx
  609.     swap    d2
  610.     dbra    d2,.oddotopx
  611.     move.b    -(a0),-(a1)
  612. .oddxx:
  613.     rts
  614. *
  615. *
  616. *
  617. .evnetopx:
  618.     swap    d2
  619. .evnevnx:
  620.     move.w    -(a0),-(a1)
  621. .doevx:
  622.     dbra    d2,.evnevnx
  623.     swap    d2
  624.     dbra    d2,.evnetopx
  625.     rts
  626. *
  627. *
  628. *    need to use byte moves
  629. .oddevtop:
  630.     swap    d2
  631. .oddeven:
  632.     move.b    -(a0),-(a1)
  633. .oddeveni:
  634.     dbra    d2,.oddeven
  635.     swap    d2
  636.     dbra    d2,.oddevtop
  637.     rts
  638.  
  639.  
  640.  
  641.  
  642. _put_pix:
  643.     move.l    _pgeptr,d0
  644.     move.w    6(sp),d1
  645.     ext.l    d1
  646.     mulu    8(sp),d1
  647.     add.l    d1,d0
  648.     move.w    4(sp),d1
  649.     ext.l    d1
  650.     divu    #8,d1
  651.     move.l    d1,d2
  652.     ext.l    d1
  653.     add.l    d1,d0
  654.     swap.w    d2
  655.     movea.w d2,a1
  656.     adda.l    _pixtbl,a1
  657.     move.b    (a1),d3
  658.     movea.l    d0,a0
  659.     or.b    d3,(a0)
  660.     rts
  661.